package com.example.mapper;


import com.example.pojo.Good;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface GoodMapper {


    List<Good> getGood(Good good);

    @Delete("delete from good where goodCode = #{id}")
    void deleteGood(String id);

    @Update("UPDATE good SET brdCode = #{brdCode}, typeCode = #{typeCode}, goodName= #{goodName}," +
            "model = #{model}, goodUnit = #{goodUnit}, marPrice = #{marPrice}, selPrice = #{selPrice}," +
            "costPrice = #{costPrice}, goodImg = #{goodImg}, goodDes = #{goodDes}, goodNum = #{goodNum},supCode=#{supCode}" +
            " WHERE goodCode = #{goodCode}")
    void updateGood(Good good);

    @Insert("INSERT INTO good values (#{goodCode}, #{brdCode}, #{typeCode},#{supCode}, #{goodName},#{model}, " +
            "#{goodUnit}, #{marPrice}, #{selPrice},#{costPrice}, #{goodImg}, #{goodDes}, #{goodNum} )")
    void addGood(Good good);

    @Update("UPDATE good SET goodNum = goodNum - #{sealNum} WHERE goodCode = #{goodCode}")
    void numChange(String goodCode, Integer sealNum);
}
